﻿using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Base
{
    public partial class Base_Role_List : BaseForm
    {
        ServiceBase service = new ServiceBase();
        public Base_Role_List()
        {
            InitializeComponent();
            BindData();
        }

        private void BindData()
        {
            using (DataTable dt = service.GetRoleTable(txtRoleName.Text.ToSafeString(), ""))
            {
                dataGridViewX1.DataSource = dt;
            }
        }
        private void benQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            GridView rows = sender as GridView;
            int[] inteurm = rows.GetSelectedRows();
            if (inteurm != null && inteurm.Length > 0)
            {
                string strRoleID = rows.Rows[inteurm[0]].DataRow["RoleID"].ToString();
                Base_Role_Option option = new Base_Role_Option(strRoleID);
                if (option.ShowDialog() == DialogResult.OK)
                {
                    BindData();
                }
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            Base_Role_Option option = new Base_Role_Option(string.Empty);
            if (option.ShowDialog() == DialogResult.OK)
            {
                this.BindData();
            }
        }

        //private void btnAuth_Click(object sender, EventArgs e)
        //{
        //    GridView rows = gridView1 as GridView;
        //    int[] inteurm = rows.GetSelectedRows();
        //    if (inteurm != null && inteurm.Length > 0)
        //    {
        //        string SpecialityKindsNO = rows.Rows[inteurm[0]].DataRow.ItemArray[0].ToString();
        //        Base_Role_Auth option = new Base_Role_Auth(SpecialityKindsNO);
        //        option.ShowDialog();
        //    }
        //    else
        //    {
        //        DevHelper.ShowInfoMessageBox("请先选择角色!");
        //    }
        //}
    }
}
